<?php

/**
 * Adverts form base class.
 *
 * @method Adverts getObject() Returns the current form's model object
 *
 * @package    explications_informatiques
 * @subpackage form
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAdvertsForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idadverts'  => new sfWidgetFormInputHidden(),
      'id_membre'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'add_empty' => true)),
      'id_auteur'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'add_empty' => true)),
      'raison'     => new sfWidgetFormTextarea(),
      'date_ajout' => new sfWidgetFormDateTime(),
      'date_fin'   => new sfWidgetFormDateTime(),
      'new_group'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardGroup'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'idadverts'  => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idadverts')), 'empty_value' => $this->getObject()->get('idadverts'), 'required' => false)),
      'id_membre'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'required' => false)),
      'id_auteur'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'required' => false)),
      'raison'     => new sfValidatorString(array('required' => false)),
      'date_ajout' => new sfValidatorDateTime(array('required' => false)),
      'date_fin'   => new sfValidatorDateTime(array('required' => false)),
      'new_group'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardGroup'))),
    ));

    $this->widgetSchema->setNameFormat('adverts[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Adverts';
  }

}
